﻿<!DOCTYPE HTML>
<html>
   <head>
   <meta charset="utf-8">
   <title>WebSocketTest</title>
    
      <script type="text/javascript">
        function WebSocketTest()
        {
           if ("WebSocket" in window)
           {
              console.log("您的浏览器支持 WebSocket!");

              var ws = new WebSocket("ws://localhost:8080/websocket?abc=html");
               
              ws.onopen = function()
              {
                 ws.send("test send abc");
                 console.log("message sending");
              };
               
              ws.onmessage = function (evt) 
              { 
                 var received_msg = evt.data;
                 console.log("received msg" + received_msg);
              };
               
              ws.onclose = function()
              { 
                 alert("close"); 
              };
           }
           
           else
           {
              alert("您的浏览器不支持 WebSocket!");
           }
        }
      </script>
        
   </head>
   <body>
   
      <div id="sse">
         <a href="javascript:WebSocketTest()">运行 WebSocket</a>
      </div>
      
   </body>
</html>